#include <xen/sched-if.h>
+static void flush_vtlb_for_context_switch(struct vcpu* vcpu)
+{
+ int last_vcpu_id =
+ vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id;
+
+ if (is_idle_domain(vcpu->domain) || last_vcpu_id == vcpu->vcpu_id)
+ return;
+ vcpu->domain->arch.last_vcpu[smp_processor_id()].vcpu_id =
+ vcpu->vcpu_id;
+ if (last_vcpu_id == INVALID_VCPU_ID)
+ return;
+
+ // if the vTLB implementation was changed,
+ // the followings must be updated either.
+ if (VMX_DOMAIN(vcpu)) {
+ // currently vTLB for vt-i domian is per vcpu.
+ // so any flushing isn't needed.
+ } else {
+ vhpt_flush();
+ }
+ local_flush_tlb_all();
+}
+
void schedule_tail(struct vcpu *prev)
{
extern char ia64_ivt;
__ia64_per_cpu_var(current_psr_ic_addr) = (int *)
(current->domain->arch.shared_info_va + XSI_PSR_IC_OFS);
}
+ flush_vtlb_for_context_switch(current);
}
void context_switch(struct vcpu *prev, struct vcpu *next)
__ia64_per_cpu_var(current_psr_ic_addr) = NULL;
}
}
+ flush_vtlb_for_context_switch(current);
local_irq_restore(spsr);
context_saved(prev);
}
int arch_domain_create(struct domain *d)
{
+ int i;
+
// the following will eventually need to be negotiated dynamically
d->arch.shared_info_va = DEFAULT_SHAREDINFO_ADDR;
d->arch.breakimm = 0x1000;
+ for (i = 0; i < NR_CPUS; i++) {
+ d->arch.last_vcpu[i].vcpu_id = INVALID_VCPU_ID;
+ }
if (is_idle_domain(d))
return 0;
DEFINE_PER_CPU (unsigned long, vhpt_paddr);
DEFINE_PER_CPU (unsigned long, vhpt_pend);
-static void vhpt_flush(void)
+void vhpt_flush(void)
{
struct vhpt_lf_entry *v = __va(__ia64_per_cpu_var(vhpt_paddr));
int i;
// atomic_t mm_users; /* How many users with user space? */
};
+struct last_vcpu {
+#define INVALID_VCPU_ID INT_MAX
+ int vcpu_id;
+} ____cacheline_aligned_in_smp;
+
struct arch_domain {
struct mm_struct mm;
unsigned long metaphysical_rr0;
void *efi_runtime;
/* Metaphysical address to fpswa_interface_t in domain firmware memory is set. */
void *fpswa_inf;
+
+ struct last_vcpu last_vcpu[NR_CPUS];
};
#define INT_ENABLE_OFFSET(v) \
(sizeof(vcpu_info_t) * (v)->vcpu_id + \